<html>
<head><meta charset="utf-8"><title>const eval UB: https://github.com/rust-lang/rfcs/pull/3016 · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html">const eval UB: https://github.com/rust-lang/rfcs/pull/3016</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230565353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230565353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230565353">(Mar 16 2021 at 18:20)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="1977">@T-lang</span> Opening this thread to follow up on our discussion about the const eval UB RFC: <a href="https://github.com/rust-lang/rfcs/pull/3016">https://github.com/rust-lang/rfcs/pull/3016</a></p>



<a name="230565497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230565497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230565497">(Mar 16 2021 at 18:20)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> Thanks for the follow-up.</p>



<a name="230565667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230565667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230565667">(Mar 16 2021 at 18:21)</a>:</h4>
<p>I wanted to start by noting that I agree with your statement that we shouldn't be guaranteeing these things. We should be stating that we want to check them if possible, while leaving room to <em>not</em> check them, such as if we want to improve CTFE performance.</p>



<a name="230565731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230565731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230565731">(Mar 16 2021 at 18:22)</a>:</h4>
<p>The question then becomes, is that what the RFC is stating?</p>



<a name="230565812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230565812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230565812">(Mar 16 2021 at 18:22)</a>:</h4>
<p>It seems, to me, like the RFC is trying to state that, and allow us to arbitrarily change this behavior in the future.</p>



<a name="230565913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230565913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230565913">(Mar 16 2021 at 18:23)</a>:</h4>
<p>I disagree. The reference section of the RFC starts with this:</p>
<div class="codehilite"><pre><span></span><code>The following kinds of UB are detected by CTFE, and will cause compilation to stop with an error:

Dereferencing dangling pointers.
Using an invalid value in an arithmetic, logical or control-flow operation.
</code></pre></div>



<a name="230566131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566131">(Mar 16 2021 at 18:25)</a>:</h4>
<p>For other cases, it says:</p>
<div class="codehilite"><pre><span></span><code>All of this UB has in common that there is an easy way to continue evaluation even though the program has caused UB: we can just access the underlying memory despite alignment and/or aliasing rules being violated, and we can just ignore the existence of an invalid value as long as it is not used in some arithmetic, logical or control-flow operation. There is no guarantee that CTFE detects such UB: evaluation may either fail with an error, or continue with the some well-defined result. In the latter case, implementations should document how evaluation will proceed, i.e., how the result is computed.
</code></pre></div>



<a name="230566256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566256">(Mar 16 2021 at 18:26)</a>:</h4>
<p>Fair. That first item is a subset of the things it proposes to detect if possible, and the statement in the RFC is that " These kinds of UB have in common that there is nothing sensible evaluation can do besides stopping with an error.". If there <em>is</em> something sensible to do in those cases, then that reasoning wouldn't hold.</p>



<a name="230566329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566329">(Mar 16 2021 at 18:26)</a>:</h4>
<p>One sensible thing to do would be to assume that code wasn't called and to eliminate it entirely from MIR.</p>



<a name="230566345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566345">(Mar 16 2021 at 18:26)</a>:</h4>
<p>(For example)</p>



<a name="230566383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566383">(Mar 16 2021 at 18:27)</a>:</h4>
<p>Ah, interesting. So, effectively, we'd be detecting UB in CTFE, but we don't guarantee to <em>do</em> CTFE on something that's not needed?</p>



<a name="230566621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566621">(Mar 16 2021 at 18:28)</a>:</h4>
<p>Sure, that seems like a reasonable way to think about it from an implementation perspective. CTFE can only detect UB present in the MIR it runs on, which means that if you present it with optimized MIR whose optimizations assume the absence of UB, you may not be able to detect the original UB.</p>



<a name="230566655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566655">(Mar 16 2021 at 18:29)</a>:</h4>
<p>OK, I think I now see your point.</p>



<a name="230566663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566663">(Mar 16 2021 at 18:29)</a>:</h4>
<p>And I agree.</p>



<a name="230566673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566673">(Mar 16 2021 at 18:29)</a>:</h4>
<p>Promising to error on user-written UB means promising that that UB exists unmodified in the MIR that CTFE runs on.</p>



<a name="230566704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566704">(Mar 16 2021 at 18:29)</a>:</h4>
<p>I <em>don't</em> want a hard requirement to avoid all optimizations that rely on the absence of UB.</p>



<a name="230566819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566819">(Mar 16 2021 at 18:30)</a>:</h4>
<p>Similarly, the guarantee to give "obvious semantics" to all undetected UB means that you can't do pre-CTFE MIR optimizations that would give the MIR "nonobvious semantics"</p>



<a name="230566944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230566944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230566944">(Mar 16 2021 at 18:31)</a>:</h4>
<p>I've just unchecked my box on the RFC, for now.</p>



<a name="230567202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230567202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230567202">(Mar 16 2021 at 18:32)</a>:</h4>
<p>I now agree with your concern, and I appreciate you clarifying it further.</p>



<a name="230567454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230567454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230567454">(Mar 16 2021 at 18:34)</a>:</h4>
<p>While there's a note elsewhere in the RFC that we do make it <em>possible</em> to provide such optimizations, the main part of the RFC seems to want to prohibit such optimizations, which seems at least inconsistent.</p>



<a name="230567574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230567574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230567574">(Mar 16 2021 at 18:34)</a>:</h4>
<p>I think we're going to have to be <em>very specific</em> about seeking further clarification, ideally in the form of a patch.</p>



<a name="230567726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230567726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230567726">(Mar 16 2021 at 18:36)</a>:</h4>
<p>I do think, on balance, that the current behavior we want from rustc <em>is</em> what the RFC specifies.</p>



<a name="230567871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230567871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230567871">(Mar 16 2021 at 18:36)</a>:</h4>
<p>In particular, I think even if we do some kind of JIT for CTFE, we want to catch things like accesses to invalid memory, and give a compilation error rather than (say) crashing or causing UB <em>in the compiler itself</em>.</p>



<a name="230568113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230568113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230568113">(Mar 16 2021 at 18:38)</a>:</h4>
<p>An invalid memory access when using a JIT could also read/write into an unrelated CTFE memory allocation without crashing or causing UB in the compiler itself.</p>



<a name="230568146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230568146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230568146">(Mar 16 2021 at 18:38)</a>:</h4>
<p>/me nods.</p>



<a name="230568173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230568173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230568173">(Mar 16 2021 at 18:39)</a>:</h4>
<p>Yes, I agree the documented behavior is the right thing for rustc at the moment. I definitely don't think CTFE UB should allow compiler UB, and would be in favor of documenting that fact.</p>



<a name="230568197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230568197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230568197">(Mar 16 2021 at 18:39)</a>:</h4>
<p>That's what I was about to propose, yeah.</p>



<a name="230568777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230568777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230568777">(Mar 16 2021 at 18:42)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> How would you feel if the RFC made the following two tweaks?<br>
1) State, up front, that the default behavior of any Rust compiler should never be for CTFE UB to result in compiler UB. (I honestly don't think Rust compilers should even offer an option for that.)<br>
2) Modify the two seemingly "hard" requirements at the start of the reference-level explanation, to state the general rule first (if evaluation can't proceed) and give those two cases as examples, along with a disclaimer that the compiler may be allowed to apply optimizations (e.g. dead code elimination or eliminating unreferenced constants) that avoids hitting those, in which case they fall under the subsequent category where they "might or might not be detected depending on the implementation".</p>



<a name="230568915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230568915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230568915">(Mar 16 2021 at 18:43)</a>:</h4>
<p>I think those two changes go hand-in-hand; the assumption of (2) is that the compiler couldn't proceed without causing (1), but if it turns out the compiler <em>can</em> then it just falls into the case where it needs to document its behavior.</p>



<a name="230569014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230569014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230569014">(Mar 16 2021 at 18:44)</a>:</h4>
<p>To give a specific example, I would prefer not to guarantee any particular compiler behavior for the following code:</p>
<div class="codehilite"><pre><span></span><code>let x = MyDropValue { ... };
let x_ptr = &amp;x as *const _;
let y = x; // x is moved
do_some_stuff_with_y(y);
read_from_ptr(x_ptr);
</code></pre></div>
<p>IMO there is no "obvious semantics" for this if we want to allow place unification on CTFE MIR.</p>



<a name="230569302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230569302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230569302">(Mar 16 2021 at 18:46)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> I think (2) winds up saying that any UB may or may not be detected depending on the implementation, since any detectable UB can be eliminated during a dead-code-elimination pass.</p>



<a name="230569383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230569383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230569383">(Mar 16 2021 at 18:47)</a>:</h4>
<p>I think that also precludes us from offering a documented semantics for any particular UB.</p>



<a name="230569725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230569725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230569725">(Mar 16 2021 at 18:49)</a>:</h4>
<p>I agree that that's the net effect of (2).</p>



<a name="230569796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230569796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230569796">(Mar 16 2021 at 18:49)</a>:</h4>
<p>In which case, we could also just fold it into the examples of UB we want to detect if possible, and not emphasize any specific cases.</p>



<a name="230569875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230569875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230569875">(Mar 16 2021 at 18:50)</a>:</h4>
<p>I'd be fine with that too.</p>



<a name="230570125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230570125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230570125">(Mar 16 2021 at 18:51)</a>:</h4>
<p>I don't suppose you'd be up for writing a patch to the RFC, to the above effect? That might be more productive than trying to summarize this conversation into a request for such a change.</p>



<a name="230570242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230570242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230570242">(Mar 16 2021 at 18:52)</a>:</h4>
<p>"We want to detect and report UB when possible, and we promise CTFE UB won't trigger compiler UB" seems like a very reasonable thing to document to me. However, I'm not sure that it belongs as a patch to the existing RFC, since I think it's a substantially different design and message.</p>



<a name="230571142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230571142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230571142">(Mar 16 2021 at 18:58)</a>:</h4>
<p>As a first step, it seems useful for you to post a quick note to the RFC, stating that point of common ground ("we promise CTFE UB won't cause UB inside the compiler"), and then stating the main point of disagreement (that beyond that no CTFE UB detection should be mandatory, and we should be able to apply optimizations that might prevent us from detecting it, such as DCE).</p>



<a name="230571167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230571167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230571167">(Mar 16 2021 at 18:59)</a>:</h4>
<p>I personally would support that.</p>



<a name="230571229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230571229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230571229">(Mar 16 2021 at 18:59)</a>:</h4>
<p>I don't think it'd be unreasonable to keep 90% of the RFC while modifying the message to be consistent with that.</p>



<a name="230571292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230571292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230571292">(Mar 16 2021 at 18:59)</a>:</h4>
<p>I do agree that it's a different approach, but I think it's the right one.</p>



<a name="230572890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230572890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230572890">(Mar 16 2021 at 19:10)</a>:</h4>
<p>i think i agree with the consensus reached here--</p>



<a name="230572909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230572909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230572909">(Mar 16 2021 at 19:10)</a>:</h4>
<p>I would never expect <em>compiler</em> UB, so there are some bounds</p>



<a name="230573148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230573148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230573148">(Mar 16 2021 at 19:12)</a>:</h4>
<p>but I think that we should either</p>
<ol>
<li>say that we will detect all UB; or,</li>
<li>say that const evaluating UB yields "undefined values" or something like that, and may yield compilation errors</li>
</ol>



<a name="230573171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230573171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230573171">(Mar 16 2021 at 19:12)</a>:</h4>
<p>If 2 is the goal of the RFC, then I think it can be made much clearer :)</p>



<a name="230573200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230573200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230573200">(Mar 16 2021 at 19:12)</a>:</h4>
<p>I am convinced that we are not ready to do 1 yet, though I think it is what I (as a user) would want</p>



<a name="230573246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230573246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230573246">(Mar 16 2021 at 19:13)</a>:</h4>
<p>It's probably not truly practical for a variety of reasons</p>



<a name="230573297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230573297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230573297">(Mar 16 2021 at 19:13)</a>:</h4>
<p>But regardless if we do 2 we have room to move to 1</p>



<a name="230579317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230579317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230579317">(Mar 16 2021 at 19:50)</a>:</h4>
<p>It sounds like we might potentially have consensus after all?</p>



<a name="230589715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230589715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230589715">(Mar 16 2021 at 20:55)</a>:</h4>
<p>I agree that (1) and (2) are the best options, and that I think we should do (2) for now, possibly moving to (1) in the future once it is both implementable and we have a clear understanding of the impact that it would have on compile times and guaranteed optimizations (I interpret (1) to mean that no/very limited optimizations are allowed on CTFE MIR).</p>



<a name="230590021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230590021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230590021">(Mar 16 2021 at 20:57)</a>:</h4>
<p>Sorry, that was long. Yes, I agree that there is consensus between the three of us. <span class="user-mention" data-user-id="116083">@pnkfelix</span> Do you agree with this?</p>



<a name="230590142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230590142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230590142">(Mar 16 2021 at 20:58)</a>:</h4>
<p>(<span class="user-mention" data-user-id="125270">@scottmcm</span> I'd of course love to hear your opinions as well)</p>



<a name="230590322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230590322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230590322">(Mar 16 2021 at 20:59)</a>:</h4>
<p>I have a question. What would "undefined value" mean? Is it merely an unspecified value (which must be valid), or could it be an invalid value, or even uninitialized?</p>



<a name="230591053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230591053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230591053">(Mar 16 2021 at 21:04)</a>:</h4>
<p><span class="user-mention" data-user-id="257758">@Connor Horman</span> My preference would be to quite literally not specify. The output may be uninitialized, may be poison, etc.</p>



<a name="230591219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230591219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230591219">(Mar 16 2021 at 21:05)</a>:</h4>
<p>So then would making it return an uninitialized value (which can be downgraded to a defined value by an implementation) be correct? I haven't seen any rust documentation that uses the term "undefined value".</p>



<a name="230591246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230591246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230591246">(Mar 16 2021 at 21:05)</a>:</h4>
<p>Doing better than that gets "tricky", since e.g. an invalid transmute of bytes into a value may result in a const reference containing garbage.</p>



<a name="230591327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230591327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230591327">(Mar 16 2021 at 21:06)</a>:</h4>
<p>I don't think undefined value is meant to be a technical term. It's just that we don't specify the result.</p>



<a name="230593032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230593032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230593032">(Mar 16 2021 at 21:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="127859">Taylor Cramer</span> <a href="#narrow/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016/near/230590021">said</a>:</p>
<blockquote>
<p>Sorry, that was long. Yes, I agree that there is consensus between the three of us. <span class="user-mention silent" data-user-id="116083">pnkfelix</span> Do you agree with this?</p>
</blockquote>
<p>It guess it sounds fine, as long as the key principle that unsafe CTFE can never cause UB in compiler itself is still upheld. Which then means that we just need to make sure that no compile-time operation on one of these “unspecified values” can ever cause UB. (Which also seems fine to me; it certainly seems like a looser guarantee than what <span class="user-mention" data-user-id="120791">@RalfJ</span> was talking about ensuring in the first place.)</p>



<a name="230597890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230597890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230597890">(Mar 16 2021 at 21:59)</a>:</h4>
<p>No worries, <span class="user-mention" data-user-id="127859">@Taylor Cramer</span>.  I like where the consensus ended up.</p>



<a name="230631505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/230631505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#230631505">(Mar 17 2021 at 03:12)</a>:</h4>
<p>I tried to summarize this discussion in a comment on the RFC: <a href="https://github.com/rust-lang/rfcs/pull/3016#issuecomment-800733571">https://github.com/rust-lang/rfcs/pull/3016#issuecomment-800733571</a><br>
Please let me know if you feel that this comment doesn't represent your views or the consensus in this channel, and I'll edit the comment. Thanks!</p>



<a name="231146015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231146015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231146015">(Mar 20 2021 at 13:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="127859">Taylor Cramer</span> <a href="#narrow/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016/near/230569302">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> I think (2) winds up saying that any UB may or may not be detected depending on the implementation, since any detectable UB can be eliminated during a dead-code-elimination pass.</p>
</blockquote>
<p>no that is not true. You need to distinguish "statically detectable UB" (look at the code and say if running that code will cause UB) from "dynamically detectable UB" (run the code in Miri/UBsan-like situations and check for all UB). Obviously, dynamic detection is much much easier than static detection. So there is a lot of trivial-to-detect UB during CTFE that will never get eliminated during a dead-code-elim pass.</p>



<a name="231146176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231146176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231146176">(Mar 20 2021 at 13:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016/near/230573148">said</a>:</p>
<blockquote>
<p>but I think that we should either</p>
<ol>
<li>say that we will detect all UB; or,</li>
<li>say that const evaluating UB yields "undefined values" or something like that, and may yield compilation errors</li>
</ol>
<p>If 2 is the goal of the RFC, then I think it can be made much clearer :)</p>
<p>I am convinced that we are not ready to do 1 yet, though I think it is what I (as a user) would want</p>
</blockquote>
<p>I think there is a reasonable middle-ground between these two extremes: promise to detect some UB that is easy to detect. This is what C++ does. (constexpr in C++ so far is so restricted that the only UB it can possibly cause is easy to detect. At least, that is my understanding.)<br>
The goal of the RFC was to hit that middle-ground.</p>
<p>I understand the lang team wants to guarantee less, and I accept that, but I want to clarify that there is a lot of gray here and I don't entirely understand why the lang team says we should do either (1) or (2) but nothing in between.</p>



<a name="231146321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231146321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231146321">(Mar 20 2021 at 13:23)</a>:</h4>
<p>The RFC looks the way it does because I aimed to make sure that Rust CTFE is at least as safe as C++ constexpr. That seemed like a reasonable lower bound to me.</p>



<a name="231149016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231149016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231149016">(Mar 20 2021 at 14:17)</a>:</h4>
<p>I think it's a good idea for rustc to <em>implement</em> CTFE that is as safe as C++ constexpr (in default modes), but I don't think it is worthwhile to have it in the spec; this makes it much harder to do optimizations on const fns, as well as making any compiler options for enabling such optimizations "nonconforming". Whether a given UB is easy to detect depends on what previous optimizations have been done, and having everything in <code>-O0</code> style seems like unnecessary compile-time overhead which some people will definitely want to opt out of.</p>



<a name="231160268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231160268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231160268">(Mar 20 2021 at 17:45)</a>:</h4>
<blockquote>
<p>but I don't think it is worthwhile to have it in the spec</p>
</blockquote>
<p>I think the Rust spec should mandate a compiler to be at least as safe as what the C++ spec mandates, even if that means not optimizing code for CTFE.<br>
But I guess this is a value judgment so there's not much more left here than to agree to disagree. For now, this won't make much of a difference anyway, since we agree on what the implementation should do. :)</p>



<a name="231160361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231160361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231160361">(Mar 20 2021 at 17:46)</a>:</h4>
<p>It just means I need to rewrite that RFC for the nth time.^^</p>



<a name="231374455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231374455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231374455">(Mar 22 2021 at 19:53)</a>:</h4>
<p>To be honest, my current feeling is that const eval should detect as much UB as possible.</p>



<a name="231374490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231374490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231374490">(Mar 22 2021 at 19:53)</a>:</h4>
<p>But I'm willing to wait until we've made more progress on defining UB to argue about it :)</p>



<a name="231375445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231375445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231375445">(Mar 22 2021 at 20:00)</a>:</h4>
<p>Saying "we detect at least this much UB" does not prevent optionally detecting more. However, saying "we detect as much as we possibly could" can prevent optimization possibilities because the optimization goes out of spec. So saying that we detect as much UB as possible, always, hurts <em>even code with no UB in it</em>, because now the code can't even be optimized without being out of spec.</p>



<a name="231375642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231375642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231375642">(Mar 22 2021 at 20:01)</a>:</h4>
<p>yeah, this is why I'm happy with a starting point of "UB is UB even at compilation time"</p>



<a name="231375693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231375693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231375693">(Mar 22 2021 at 20:01)</a>:</h4>
<p>Also, saying "we detect at least this much" is an advance commitment that we're willing to make that trade-off, even though we might not know what we're trading off yet.</p>



<a name="231375764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231375764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231375764">(Mar 22 2021 at 20:02)</a>:</h4>
<p>it seems like we should just have debug_assert and opt-level type settings for const eval as well as normal compilation</p>



<a name="231441331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231441331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231441331">(Mar 23 2021 at 09:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016/near/231375764">said</a>:</p>
<blockquote>
<p>it seems like we should just have debug_assert and opt-level type settings for const eval as well as normal compilation</p>
</blockquote>
<p>having those separate settings presupposes that we have separate MIR for CTFE</p>



<a name="231441433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231441433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231441433">(Mar 23 2021 at 09:22)</a>:</h4>
<p>the largest cost to detecting UB is having that separate MIR, so adding these options is almost as bad as just saying that we won't optimize</p>



<a name="231441445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231441445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231441445">(Mar 23 2021 at 09:22)</a>:</h4>
<p>(unless we do some special magic where we share the MIR in case the options are identical for CTFE and runtime)</p>



<a name="231441481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/231441481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#231441481">(Mar 23 2021 at 09:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016/near/231375693">said</a>:</p>
<blockquote>
<p>Also, saying "we detect at least this much" is an advance commitment that we're willing to make that trade-off, even though we might not know what we're trading off yet.</p>
</blockquote>
<p>I see, so the main motivation here is to avoid drawing ourselves into a corner. I can see that, thanks for explaining.</p>



<a name="237330391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/237330391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#237330391">(May 04 2021 at 14:06)</a>:</h4>
<p>Hey, <span class="user-mention" data-user-id="120791">@RalfJ</span> : I’m working on merging RFC PR <a href="https://github.com/rust-lang/rust/issues/3016">#3016</a>, and I wanted to double-check: The plan is <em>not</em> to actually add a feature gate that would control the phasing in of any behavior here, right?</p>



<a name="237330492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/237330492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#237330492">(May 04 2021 at 14:07)</a>:</h4>
<p>I.e., my memory from what the RFC says and from prior discussions, the RFC is codifying what the compiler already does (or what we intend for it to do), and there is nothing to actually phase in (that we know of). Does that all sound correct?</p>



<a name="237332883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/237332883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#237332883">(May 04 2021 at 14:23)</a>:</h4>
<p>Yes. The only requirement of the RFC is to not let CTFE UB "explode" during <br>
compilation, and we already satisfy that. The "what rustc does" part of the RFC <br>
is also already implemented, as far as I know.<br>
(replying by mail)</p>



<a name="237404362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/const%20eval%20UB%3A%20https%3A//github.com/rust-lang/rfcs/pull/3016/near/237404362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/const.20eval.20UB.3A.20https.3A.2F.2Fgithub.2Ecom.2Frust-lang.2Frfcs.2Fpull.2F3016.html#237404362">(May 04 2021 at 21:36)</a>:</h4>
<p>okay; merged!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>